# -*-encoding: utf-8 -*-

import threading
import pg
from Connection_PG import pg_conn

class PostgrePoolThread(threading.Thread):

    #sql = ""
    #query = None
    #param = None

    def __init__(self, sql, *param):
        threading.Thread.__init__(self)
        self.sql = sql
        self.param = param
    def run(self):
        inputSql = (self.sql) % (self.param)
        self.query = pg_conn.query(inputSql)
    def showResult(self):
        return self.query.dictresult()
    def showAffectedRows(self):
        return self.query

#updateSQL = "UPDATE user_image_info SET path = 'www888' WHERE md5 = '096241b4c7bf2e59f5b3e5e9f2bfcaed' AND user_id = '6'"
##updateSQL = '''
##INSERT INTO user_image_info (md5, path, user_id) VALUES('aaa', 'bbb', 4)
##'''
#
#print 1
#mQuery = PySQLPool.getNewQuery(mConn)
#mQuery.commitOnEnd = True
#print 2
#mQuery.Query(updateSQL)
##mQuery.execute(updateSQL)
#print 3
#print mQuery.affectedRows
#print dir(mQuery)
#print mQuery.commitOnEnd
#for row in mQuery.record:
#    print row['ID']
